home *** CD-ROM | disk | FTP | other *** search
- Documentation for RUBBER
- Copyright (c) 1996 David Bollinger
- 103057.1460@compuserve.com
-
- My $.02 on the topic of image warping:
- (I assume we all know what x's and y's and u's and v's are?)
- It all boils down to finding some way to convert between source and
- destination coordinates. If you have a screen image measured with x's and
- y's and a texture image measured with u's and v's, then the question is simply
- "How do you convert an x to a u?" Or vice versa. Or y to v, or vice versa.
-
- Well, all you need is an equation. Here's one:
-
- u = x
- v = y
-
- That will basically just do a straight copy of the image. For every pixel
- on the destination, the same pixel on the source will be read to provide the
- color.
- Hm, but that's not very exciting, is it? How about this one:
-
- u = a + b*Y + c*X + d*Y*Y + e*X*Y + f*X*X
- v = g + h*Y + i*X + j*Y*Y + k*X*Y + l*X*X
-
- a and g are the intercepts, and b-f,h-l are the coefficients. If you're
- after a specific effect you can think about what each value does (a and g
- are simple translation, c and h will scale linearly in X/Y respectively,
- others will rotate, skew and otherwise mess with it...) although I won't
- attempt to figure it all out for you. ;>
- The important point, though, is that you can use whatever equation you
- want. You can leave out terms if they're not used to increase speed, you
- can use higher order polys, toss in some trig functions -- whatever you need
- to get the job done. There's nothing special about the one listed above,
- other than it's the one used in the source code. It's complex enough to be
- fun, but not too complex to be impossible to figure out.
-
- The source code:
- OK, so it's not fast - it uses floating point math liberally. The
- purpose here isn't to show you how to optimize code, but to explain the
- technique. I did rearrange the equation a little in the source code to
- improve performance, but it is the same one presented above.
-
- So what's the practical value?
- Well you could flood the scene with image warping demos. <g> Or you can
- animate your textures - flowing lava, wavy water, hm, sound familiar? <bg>
- The demo values in RUBBER give you a hint as to what is possible, but BY
- NO MEANS come even close to exhausting the possibilities of this single
- equation. Obviously, you can get cool animated warping effects too - just
- start with a set of coefficients that you like and modify them by slight
- amounts within a loop, that's what happens in RUBBERA - a very tame example
- of ONE of the types of animation you might achieve.
-
- Want more info?
- All of this is well-known stuff, you just gotta know where to look for
- it. Good library search topics might include Digital Image Processing and
- G.I.S. (Geographic Information Systems - especially Photo Rectification).
-
- That's all,
- Dave
-